package com.woniuxy.oa.entity;

import java.util.List;

public class PersonnelPageBean<T> {
	private List<T> beanList;
	//当前页
	private Integer currentPage;
	//页大小
	private Integer pageSize;
	//总记录条数,计算
	private Integer totalRecord;
	//总页数,计算
	private Integer totalPage;
	//开始页
	private Integer beginPage;
	//结束页
	private Integer endPage;
	//URL
	private String url;
	//与employee属性符合的条件
	private Employee empCondition;
	//年龄区间的开始
	private Integer beginAge;
	//年龄区间的结束
	private Integer endAge;
	//排序属性
	private String orderedField;
	//是否降序，需要使用默认值，不使用封装类
	private boolean descendFlag;
	
	public PersonnelPageBean() {	
	}
	
	public List<T> getBeanList() {
		return beanList;
	}

	public void setBeanList(List<T> beanList) {
		this.beanList = beanList;
	}
	
	public Integer getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(Integer currentPage) {
		this.currentPage = currentPage;
	}
	
	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}
	
	public Integer getTotalRecord() {
		return totalRecord;
	}
	
	public void setTotalRecord(Integer totalRecord) {
		this.totalRecord = totalRecord;
	}
	
	public Integer getTotalPage() {
		return totalPage;
	}
	
	// 总页数,由总页数/页大小计算得到
	public void setTotalPage() {
		if(pageSize!=0) {
			this.totalPage = totalRecord%pageSize==0
					?totalRecord/pageSize:totalRecord/pageSize+1;
		}
	}
	
	public Integer getPageBegin() {
		return beginPage;
	}
	
	public Integer getPageEnd() {
		return endPage;
	}
	
	//计算开始页和结束页,默认最大展示页数为10
	public void setBeginPageAndEndPage() {
		if(getTotalPage()<10) {
			beginPage=1;
			endPage=getTotalPage();
		}else {
			beginPage=currentPage-5;
			endPage=currentPage+4;
			if(currentPage-5<1) {
				beginPage=1;
				endPage=10;
			}
			if(currentPage+4>getTotalPage()) {
				beginPage=getTotalPage()-9;
				endPage=getTotalPage();
			}
		}
	}
	
	public Employee getEmpCondition() {
		return empCondition;
	}

	public void setEmpCondition(Employee empCondition) {
		this.empCondition = empCondition;
	}

	public Integer getBeginAge() {
		return beginAge;
	}

	public void setBeginAge(Integer beginAge) {
		this.beginAge = beginAge;
	}

	public Integer getEndAge() {
		return endAge;
	}

	public void setEndAge(Integer endAge) {
		this.endAge = endAge;
	}

	public String getOrderedField() {
		return orderedField;
	}

	public void setOrderedField(String orderedField) {
		this.orderedField = orderedField;
	}
	//springboot调用is方法判断boolean
	public boolean isDescendFlag() {
		return descendFlag;
	}

	public void setDescendFlag(boolean descendFlag) {
		this.descendFlag = descendFlag;
	}

	public PersonnelPageBean(List<T> beanList, Integer pageIndex, Integer pageSize, Integer totalRecord, Integer totalPage,
			Integer pageBegin, Integer pageEnd) {
		super();
		this.beanList = beanList;
		this.currentPage = pageIndex;
		this.pageSize = pageSize;
		this.totalRecord = totalRecord;
		this.totalPage = totalPage;
		this.beginPage = pageBegin;
		this.endPage = pageEnd;
	}

	@Override
	public String toString() {
		return "PageBean [beanList=" + beanList + ", pageIndex=" + currentPage + ", pageSize=" + pageSize
				+ ", totalRecord=" + totalRecord + ", totalPage=" + getTotalPage() + ", pageBegin=" + beginPage
				+ ", pageEnd=" + endPage + "]";
	}

}
